<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>3、混合继承（原型继承和类继承）</title>
</head>
<body>
<script>
  function Person(name, age) {
    this.name = name;
    this.age = age;
  }

  Person.prototype.id = 10;
  Person.prototype.userInfo = function () {
    console.log('姓名：' + this.name + ",age:" + this.age)
  }

  function Boy(name, age, sex) {
    Person.call(this, name, age);
    this.sex = sex;
  }

  // 原型继承实现  参数为空 代表 父类的实例和父类的原型对象的关系了
  Boy.prototype = new Person()// father 实例对象

  var boy = new Boy('linqinghu', 23, '男');
  var boy2 = new Boy('boy2', 23, '男');
  console.log(boy.name);//linqinghu
  console.log(boy.id);//10
  boy.userInfo()//姓名：linqinghu,age:23
  console.log(boy2.name);//boy2
  console.log(boy2.id);//10
  boy2.userInfo()//姓名：boy2,age:23
</script>
</body>
</html>